package com.example.sudokusolver;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.ViewSwitcher.ViewFactory;

public class TutorialScreen8 extends Activity
{
	private TextSwitcher switcher;
	Button btnShowAnswer, btnPrevious, btnMainMenu;
	
	String textToShow[]={"Yellow = 4\tRed = 1\nGreen = 6\tBlue = 3"};
	int messageCount=textToShow.length;
	int currentIndex=-1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tutorial_screen8);
		
		btnShowAnswer = (Button) findViewById(R.id.show_answer_button);
		btnPrevious = (Button) findViewById(R.id.previous_button);
		btnMainMenu = (Button) findViewById(R.id.main_menu_button);
		
		switcher = (TextSwitcher) findViewById(R.id.question_answer_switcher);
		
		switcher.setFactory(new ViewFactory()
		{
			public View makeView()
			{
				TextView myText = new TextView(TutorialScreen8.this);
				myText.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
				myText.setTextSize(36);
				return myText;
			}
		});
		
		Animation in = AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left);
		Animation out = AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right);
		
		switcher.setInAnimation(in);
		switcher.setOutAnimation(out);
		
		btnShowAnswer.setOnClickListener(new View.OnClickListener()
		{
			public void onClick(View v)
			{
				currentIndex++;
				if(currentIndex==messageCount)
					currentIndex=0;
				switcher.setText(textToShow[currentIndex]);
			}
		});
		btnPrevious.setOnClickListener(new View.OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(v.getContext(), TutorialScreen7.class);
				startActivity(intent);
				finish();
			}
		});
		btnMainMenu.setOnClickListener(new View.OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent(v.getContext(), MainScreen.class);
				startActivity(intent);
				finish();
			}
		});
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.tutorial_screen8, menu);
		return true;
	}
	
}
